/**
*@author       wuwg
*@createTime   2018/06/03
*@updateTime   2018/06/03
*@description
*@rule
 */
@import '../../../config/config.less';
@import '../../../mixins/input/input-mixins.less';
@import '../../../mixins/common/index.less';

.@{css-prefix}select-dropdown {
  overflow: hidden;
  max-height: initial;
}

.@{css-prefix}select-dropdown-transfer-search {
  z-index: 1070;
}

@css-prefix-organ-tree: ~"@{css-prefix}organ-tree";

.organ-tree-error(~"@{css-prefix-form-item}");

// 容器
.@{css-prefix-organ-tree} {
  //z-index: 1; // 让浏览器自动获取 z-index,浏览器的容错机制，不兼容再处理
  display: inline-block;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  vertical-align: middle;
  color: @text-color;
  font-size: @font-size-base;
  //position: relative;
  line-height: normal;

  &-button-contain {
    padding: 8px 10px 3px;
    border-top: 1px solid @border-color-base;
    text-align: right;
  }

  // 值容器
  &-selection {
    display: block;
    box-sizing: border-box;
    outline: none;
    user-select: none;
    cursor: pointer;
    position: relative;

    min-height: 30px;
    background-color: #fff;
    border-radius: @btn-border-radius;
    border: 1px solid @border-color-base;
    transition: all @transition-time @ease-in-out;

    // 箭头
    .@{css-prefix-organ-tree}-arrow:nth-of-type(1) {
      display: none;
      cursor: pointer;
    }

    // 划过样式
    &:hover {
      .hover();

      .@{css-prefix-organ-tree}-arrow:nth-of-type(1) {
        display: inline-block;
      }
    }
  }

  &-show-clear &-selection:hover .@{css-prefix-organ-tree}-arrow:nth-of-type(2) {
    display: none;
  }

  //  值箭头
  &-arrow {
    .inner-arrow();
  }

  // 显示下拉菜单时样式
  &-visible {

    /*z-index: 2;*/
    // 修改遮挡不住必填校验信息问题
    // 值容器样式
    .@{css-prefix-organ-tree}-selection {
      .active();
    }

    //  值箭头
    .@{css-prefix-organ-tree}-arrow:nth-of-type(2) {
      transform: rotate(180deg);
    }
  }

  // 获取焦点
  &:focus {
    outline: 0;

    .@{css-prefix-organ-tree}-selection {
      .active();
    }
  }

  //  禁用样式
  &-disabled {

    // 值容器样式
    .@{css-prefix-organ-tree}-selection {
      .disabled();

      //  值箭头
      .@{css-prefix-organ-tree}-arrow:nth-of-type(1) {
        display: none;
      }

      //  禁用划过的样式
      &:hover {
        border-color: @border-color-base;
        box-shadow: none;

        .@{css-prefix-organ-tree}-arrow:nth-of-type(2) {
          display: inline-block;
        }
      }
    }
  }

  // 单选下的值容器样式
  &-single &-selection {
    height: @input-height-base;
    position: relative;

    // 占位字符颜色
    .@{css-prefix-organ-tree}-placeholder {
      color: @input-placeholder-color;
    }

    // 占位字符和值盒子样式
    .@{css-prefix-organ-tree}-placeholder,
    .@{css-prefix-organ-tree}-selected-value {
      display: block;
      height: @input-height-base - 2px;
      line-height: @input-height-base - 2px;
      font-size: @font-size-small;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      padding-left: 8px;
      padding-right: 24px;
    }
  }

  // 单选时input 样式，
  &-single &-input {
    width: 100%;
  }

  // 多选下的值容器样式
  &-multiple &-selection {
    padding: 0 24px 0 4px;
    //min-height: @input-height-base;

    // 占位字符颜色
    .@{css-prefix-organ-tree}-placeholder {
      display: block;
      height: @input-height-base - 2px;
      line-height: @input-height-base - 2px;
      color: @input-placeholder-color;
      font-size: @font-size-small;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      padding-left: 4px;
      padding-right: 22px;
    }
  }

  // 大型单选的值容器样式
  &-large&-single &-selection {
    height: @input-height-large;

    // 占位字符和值盒子样式
    .@{css-prefix-organ-tree}-placeholder,
    .@{css-prefix-organ-tree}-selected-value {
      height: @input-height-large - 2px;
      line-height: @input-height-large - 2px;
      font-size: @font-size-base;
    }
  }

  // 大型多选下的值容器样式
  &-large&-multiple &-selection {
    min-height: @input-height-large;

    // 占位字符和值盒子样式
    .@{css-prefix-organ-tree}-placeholder,
    .@{css-prefix-organ-tree}-selected-value {
      min-height: @input-height-large - 2px;
      line-height: @input-height-large - 2px;
      font-size: @font-size-base;
    }
  }

  // 小型单选的值容器样式
  &-small&-single &-selection {
    height: @input-height-small;
    border-radius: @btn-border-radius-small;

    // 占位字符和值盒子样式
    .@{css-prefix-organ-tree}-placeholder,
    .@{css-prefix-organ-tree}-selected-value {
      height: @input-height-small - 2px;
      line-height: @input-height-small - 2px;
    }
  }

  // 小型多选的值容器样式
  &-small&-multiple &-selection {
    min-height: @input-height-small;
    border-radius: @btn-border-radius-small;

    // 占位字符和值盒子样式
    .@{css-prefix-organ-tree}-placeholder,
    .@{css-prefix-organ-tree}-selected-value {
      height: auto;
      min-height: @input-height-small - 2px;
      line-height: @input-height-small - 2px;
    }
  }

  &-input {
    display: inline-block;
    height: @input-height-base;
    line-height: @input-height-base;
    padding: 0 22px 0 8px;
    font-size: @font-size-small;
    outline: none;
    border: none;
    box-sizing: border-box;
    color: @input-color;
    background-color: transparent;
    position: relative;
    cursor: pointer;
    .placeholder();

    &[disabled] {
      cursor: @cursor-disabled;
      color: #ccc;
    }
  }

  &-search-list {
    list-style: none;

    &-item {
      position: relative;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      margin: 0;
      line-height: normal;
      padding: 7px 16px;
      clear: both;
      color: #657180;
      font-size: 12px !important;
      list-style: none;
      cursor: pointer;
      transition: background .2s ease-in-out;

      &:hover {
        background: #f3f3f3;
      }

      &.focus {
        background: #f3f3f3;
      }

      span {
        display: block;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }

      em {
        color: #f60;
        font-style: inherit;
      }
    }
  }

  // 没有下拉数据条目的样式
  &-not-found {
    text-align: center;
    color: @btn-disable-color;

    li:not([class^=ivu-]) {
      margin-bottom: 0;
    }
  }

  // 加载文字的样式
  &-loading {
    text-align: center;
    color: @btn-disable-color;
  }

  // 多选标签的样式
  &-multiple .@{css-prefix}tag {
    height: 24px;
    line-height: 22px;
    margin: 3px 4px 3px 0;
  }

  // 大型多选标签的样式
  &-large&-multiple .@{css-prefix}tag {
    height: 28px;
    line-height: 26px;
    font-size: @font-size-base;
  }

  // 小型多选标签的样式
  &-small&-multiple .@{css-prefix}tag {
    height: 17px;
    line-height: 15px;
    font-size: @font-size-small;
    padding: 0 6px;
    margin: 3px 4px 2px 0;
  }
}

.organ-tree-error(@class) {
  .@{class}-error {
    .@{css-prefix-organ-tree} {
      &-selection {
        border: 1px solid @error-color  !important;
      }

      &-arrow {
        color: @error-color;
      }

      &-visible .@{css-prefix-organ-tree}-selection {
        .active-error();
      }
    }

    // 划过
    .@{css-prefix-organ-tree}:hover {
      .@{css-prefix-organ-tree}-selection {
        .hover-error();
      }
    }

    // 获得焦点
    .@{css-prefix-organ-tree}:focus {
      .@{css-prefix-organ-tree}-selection {
        .active-error();
      }
    }
  }
}
